line = input("请输入n和n个整数：\n").strip()
parts = list(map(int, line.split()))
if len(parts) < 2:
    print("数据太少！")
else:
    n = parts[0]
    nums = parts[1:]
    if len(nums) != n:
        print("输入个数与n不符！")
    else:
        distinct = list(set(nums))
        if len(distinct) < 2:
            print("不同的元素少于2个，无法找到最大值和次大值。")
        else:
            distinct.sort(reverse=True)
            max1 = distinct[0]
            max2 = distinct[1]
            print(max1, max2)
